package com.park.utils.fee;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;

import java.math.BigDecimal;

/**
 * @author ZhangHaiWen
 * @title: FeeUtils
 * @projectName park
 * @description: 停车费用计算公式
 * @date 2020/5/720:02
 */
public class FeeUtils {

    /**
 　　* @description: 计算按照小时收费
 　　* @param [start, end, fee]
 　　* @return {@link BigDecimal}
 　　* @throws
 　　* @author ZhangHaiWen
 　　* @version 2.0
 　　* @date 2020/5/7 20:15
 　　*/
    public static BigDecimal feeCalculat(Long start,Long end,BigDecimal fee){
        long seconds = DateUtil.between(DateUtil.date(start), DateUtil.date(end), DateUnit.SECOND);
        long hour = 0;
        hour = seconds/3600;
        if(seconds%3600!=0){
            hour = hour + 1;
        }
        System.out.println("时间间隔："+hour);
        return fee.multiply(new BigDecimal(hour));
    }
/*
    public static void main(String[] args) {
        String start = "2020-05-01 20:00:00 ";
        Date startdate = DateUtil.parse(start);

        String end = "2020-05-01 20:00:01 ";
        Date enddate = DateUtil.parse(end);

        BigDecimal bigDecimal = feeCalculat(startdate.getTime(), enddate.getTime(), new BigDecimal(2));
        System.out.println(bigDecimal);
    }*/

}
